/**
 * 试题标签分类枚举
 *
 * @author System
 * @version 2.0.0
 * @since 2025-11-11
 */
package com.edu.exam.enums.questionbank;

import com.edu.exam.enums.core.BaseEnum;

public enum QuestionTagCategory implements BaseEnum {
    ACADEMIC("ACADEMIC", "学术"),
    TECHNICAL("TECHNICAL", "技术"),
    SKILL("SKILL", "技能"),
    CONCEPT("CONCEPT", "概念"),
    DIFFICULTY("DIFFICULTY", "难度"),
    TYPE("TYPE", "题型"),
    CUSTOM("CUSTOM", "自定义");

    private final String code;
    private final String description;

    QuestionTagCategory(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static QuestionTagCategory fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("QuestionTagCategory code cannot be null or empty");
        }
        for (QuestionTagCategory category : values()) {
            if (category.getCode().equals(code)) {
                return category;
            }
        }
        throw new IllegalArgumentException("Unknown question tag category code: " + code);
    }

    public static QuestionTagCategory fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("QuestionTagCategory description cannot be null or empty");
        }
        for (QuestionTagCategory category : values()) {
            if (category.getDescription().equals(description)) {
                return category;
            }
        }
        throw new IllegalArgumentException("Unknown question tag category description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}